jQuery(window).load(function() {
/* Navigation */
	jQuery('#submenu ul.sfmenu').superfish({ 
		delay:       500,								// 0.1 second delay on mouseout 
		animation:   { opacity:'show',height:'show'},	// fade-in and slide-down animation 
		dropShadows: true								// disable drop shadows 
	});	
	

/* Hover block */

	jQuery('.portfolio-box').hover(function(){
			jQuery(this).find('div').animate({opacity:'1'},{queue:false,duration:500});
	}, function(){
			jQuery(this).find('div').animate({opacity:'0'},{queue:false,duration:500});
		});

	
/* equal column	 */
	
	  var biggestHeight = 0;  
    //check each of them  
    jQuery('.equal_height').each(function(){  
        //if the height of the current element is  
        //bigger then the current biggestHeight value  
        if(jQuery(this).height() > biggestHeight){  
            //update the biggestHeight with the  
            //height of the current elements  
            biggestHeight = jQuery(this).height();  
        }  
    });  
    //when checking for biggestHeight is done set that  
    //height to all the elements  
    jQuery('.equal_height').height(biggestHeight);  
    //cài css cho iframe them album/anh
    jQuery(".toggle_button").click(function()
    {
	    if(jQuery("#secondary").is(":visible"))
	    {
            jQuery("#secondary").hide(500);
	    	jQuery("#toggle_icon").css({'transition-duration': '0.5s','-webkit-transform' : 'rotate(90deg)',
                 '-moz-transform' : 'rotate(90deg)',
                 '-ms-transform' : 'rotate(90deg)',
                 'transform' : 'rotate(90deg)'});
	    	var r=jQuery("iframe").width()+100;
	    	if (r>1300)
	    		jQuery("#primary").css({'transition-duration': '0.5s','-webkit-transition':'margin-left 0.5s','margin-left':'50px' });
	    	else
	    		jQuery("#primary").css({'transition-duration': '0.5s','-webkit-transition':'margin-left 0.5s','margin-left':'150px' });

	    }
	    else
	    {
            jQuery("#secondary").show(500);

            jQuery("#secondary").css({'transition-duration': '0.5s','-webkit-transition':'width 150px','width':'150px' });
	    	jQuery("#toggle_icon").css({'transition-duration': '0.5s','-webkit-transform' : 'rotate(0deg)',
                 '-moz-transform' : 'rotate(0deg)',
                 '-ms-transform' : 'rotate(0deg)',
                 'transform' : 'rotate(0deg)'});
	    	jQuery("#primary").css({'transition-duration': '0.5s','-webkit-transition': 'margin-left 0.5s','margin-left':'150px' });
	    }
	});
	

});

jQuery(document).ready(function(){
    //tao doi tuong websocket
   // var wsUri = "ws://localhost:9070/server.php";   
   // wsocket = new WebSocket(wsUri); 
    
    //khi ket noi duoc mo
    //khi nhan dc message tu sever
    //    wsocket.onmessage = function(ev) {
    //     var msg = JSON.parse(ev.data); //chuyen chuoi JSON thanh doi tuong JSON
    //     var type = msg.notification_type; //kieu message
    //     var counter=msg.counter;
    //     if(type == 'like') //neu la message cua user
    //     {
    //         jQuery('.comment_counter').css({opacity: 0});
    //         jQuery('.comment_counter').text(counter);
    //         jQuery('.comment_counter').css({top: '-10px'});
    //         jQuery('.comment_counter').animate({top: '-2px', opacity: 1});
    //     }
    //     if(type == 'comment') //neu la message cua he thong
    //     {
    //         jQuery('.like_counter').css({opacity: 0});
    //         jQuery('.like_counter').text(counter);
    //         jQuery('.like_counter').css({top: '-10px'});
    //         jQuery('.like_counter').animate({top: '-2px', opacity: 1});
    //     }
    //      if(type == 'image') //neu la message cua he thong
    //     {
    //         jQuery('.image_counter').css({opacity: 0});
    //         jQuery('.image_counter').text(counter);
    //         jQuery('.image_counter').css({top: '-10px'});
    //         jQuery('.image_counter').animate({top: '-2px', opacity: 1});
    //     }
    //      if(type == 'message') //neu la message cua he thong
    //     {
    //         jQuery('.image_counter').css({opacity: 0});
    //         jQuery('.image_counter').text(counter);
    //         jQuery('.image_counter').css({top: '-10px'});
    //         jQuery('.image_counter').animate({top: '-2px', opacity: 1});
    //     }
    // };
    });